/**
 * \* Created with IntelliJ IDEA.
 * \* User: 冯若航
 * \* Date: 2021/4/29
 * \* Time: 21:11
 * \* To change this template use File | Settings | File Templates.
 * \* Description:
 * \
 */
public class 二进制中1的个数 {
    // you need to treat n as an unsigned value
    public int hammingWeight(int n) {
        int res=0;
        while(n!=0){
            res+=(n&1);
            n>>>=1;
        }
        return res;
    }
}